<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="120px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="门店" prop="storeId">
                <el-select
                  v-model="queryParams.storeId"
                  placeholder="请选择"
                  filterable
                  clearable
                  collapse-tags
                  class="w-300"
                >
                  <el-option
                    v-for="(item, index) in $store.state.user.stores"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <div class="timebox">
                <el-form-item label="日期时间" prop="date">
                  <el-date-picker
                    v-model="queryParams.date"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
              </div>
            </el-col>

            <el-col :span="6">
              <el-form-item label="未出勤天数" prop="maxDay">
                <el-input-number
                  v-model="queryParams.maxDay"
                  :precision="0"
                  :step="1"
                  :min="0"
                  class="w-300 text-left"
                  :controls="false"
                  placeholder="请输入未出勤天数"
                ></el-input-number>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>

    <div class="table_card">
      <!-- 上部分 title -->
      <div class="table_card_top">
        <span class="solid_left1"></span>
        <div class="table_card_title">考勤异常人员(连续天)</div>
      </div>

      <div class="table_list">
        <el-table :data="AttendanceList">
          <el-table-column
            prop="storeName"
            label="门店名称"
            align="center"
            fixed="left"
          >
          </el-table-column>

          <el-table-column label="姓名" align="center" prop="userName">
          </el-table-column>

          <el-table-column label="艺名" align="center" prop="stageName">
          </el-table-column>

          <el-table-column label="未上班天数" align="center" prop="workNotDay">
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import { getNoWorkContinuousDay } from "@/api/bpm/attendance";
import timer from "@/components/getTime/timer";
import { monthDays } from "@/utils/utils";
import { dayDataTime } from "@/utils/utils";
export default {
  name: "Storeadminattendanceabnormaltoday",
  components: { timer },
  data() {
    return {
      loading: false,
      exportLoading: false,
      saveLoading: false,
      value: "",
      queryParams: {
        date: [],
        startDate: "",
        endDate: "",
        storeId: "",
        maxDay: "",
      },
      AttendanceList: [],
      total: 0,
      exportLoading: false,

      minDate: "",
    };
  },

  computed: {},

  mounted() {},

  created() {
    //   const date = dayDataTime("obj");
    //   console.log(date);
    //   let startDate = date.y + "-" + date.m + "-01";
    //   let endDate = date.str;
    //   this.queryParams.date = [startDate, endDate];
    //   this.getList();
  },

  methods: {
    // 筛选
    handleQuery() {
      // this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$nextTick(() => {
        this.$refs[formName].resetFields();
      });
    },

    // 考勤异常人员
    getList() {
      this.loading = true;

      if (!this.queryParams.storeId) {
        this.$message.error("门店不能为空");
        return false;
      }

      if (!this.queryParams.date) {
        this.$message.error("日期时间不能为空");
        return false;
      }

      if (this.queryParams.date.length === 0) {
        this.$message.error("日期时间不能为空");
        return false;
      }

      const query = JSON.parse(JSON.stringify(this.queryParams));

      if (!!query.date) {
        query.startDate = this.queryParams.date[0];
        query.endDate = this.queryParams.date[1];
        delete query.date;
      }

      getNoWorkContinuousDay(query)
        .then((res) => {
          console.log(res);
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.AttendanceList = data;
            this.total = data.total;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.solid_left1 {
  margin-left: 24px;
}
.goodTop {
  width: 100%;
  height: 48px;
  background: #ffffff;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  line-height: 48px;
  padding-left: 16px;
  .good_list {
    margin-right: 32px;
  }

  .good_active {
    color: #0052d9;
    border-bottom: 1px solid #0052d9;
  }
}

.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.Order_box {
  display: flex;
  margin-left: -50px;
  .select_ipt {
    width: 130px;
    margin-right: 10px;
  }
}

.pay_ipt {
  margin-left: 50px;
}

.order_ipt {
  margin-left: -120px;
}

.timebox {
  margin-top: 10px;
}

.table_list {
  padding-bottom: 24px;

  .red {
    color: red;
  }
  .green {
    color: green;
  }
  .blue {
    color: blue;
  }
}
</style>
